-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
table: RenderTSV to render in tab-separated-values format #277
Conversation
Pull Request Test Coverage Report for Build 6409214047
💛 - Coveralls |
Hey @rafiramadhana thanks a lot for contributing this feature. Code looks good, but I have one concern. I believe that columns in TSV format are not allowed to have One option I'm thinking of is replacing |
@rafiramadhana It looks like you can double-quote columns which contain CSV:
TSV: a "b c" "d
e" Can you please make this change in the logic? if strings.ContainsAny(col, "\t\n") {
out.WriteString(fmt.Sprintf("\"%s\"", col))
} else {
out.WriteString(col)
} |
Yes, that is correct as mentioned in Wikipedia Sry, I haven't implement it because I rarely use a TSV
Agree, I think we can start with this implementation of adding double-quote |
Do we need to escape the double-quote if the columns have double-quote?
This is similar with what is done in CSV (rfc4180) |
I'm not sure what the spec calls for. But pasting |
Add .tsv handling for tabs, newlines, and doubel quotes.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
out.WriteRune('\t') | ||
} | ||
|
||
if strings.ContainsAny(col, "\t\n\"") || strings.Contains(col, " ") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jedib0t It looks like \t
gets replaced by " "
(4 spaces) in render_init.go#46
So, that's why I'm adding strings.Contains(col, " ")
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I'll have to refactor the original function. This may not be ideal behavior for the end-user.
Thanks @rafiramadhana for your contribution. Will cut a tag with this fix in a day or two. |
Tag with this feature: https://github.com/jedib0t/go-pretty/releases/tag/v6.4.8 |
Proposed Changes
RenderTSV() string
toWriter
interfaceRenderTSV()
implementationFixes #276 .
@jedib0t @dinhani